<?php

session_start();

include 'objects/User.inc';
$user = new User();

if (isset($_POST["usuario"]) && isset($_POST["clave"])) {
    $user->nombre = $_POST["usuario"];
    $user->rawClave($_POST["clave"]);
    
    if ($user->login()) {
        $_SESSION["user"] = serialize($user);
        header("Location: menu.php");
        exit();
    }
    $_SESSION["user"] = serialize($user);
} 

header("Location: index.php");

?>
